<link href="build/viewer/viewer.min.css" rel="stylesheet" type="text/css" media="screen"/>
<script src="build/viewer/viewer.min.js" type="text/javascript"></script>
<style>
.images li{
	list-style: none;
	float:left;
	padding:10px;
}
img{
	cursor:pointer;
}
</style>
<div class="pageContent">

<form method="post" action="admin/merch/uploadFile" class="pageForm required-validate" enctype="multipart/form-data" onsubmit="return iframeCallback(this, navTabAjaxDone);">
		<input type="hidden" name="merchCode" value="#(merch.code)">
		<div class="pageFormContent " layoutH="396">
			
		<div class="divider"></div>
				<label>商户新文件上传：</label>
				<ul id="upload-preview7" class="upload-preview7"></ul>
				<div class="upload-wrap" rel="#upload-preview7">
					<input type="file" name="file3" onchange="filefujianChange(this);" accept="image/*" multiple="multiple">
				</div>
				  	
		</div>
		<div class="formBar">
			<ul>
			
			<li><div class="buttonActive"><div class="buttonContent"><button type="submit">提交新文件</button></div></div></li>
			
				<li>
					<div class="button"><div class="buttonContent"><button type="button" class="close">取消</button></div></div>
				</li>
			</ul>
		</div>
	</form>


<form method="post" action="#" class="pageForm required-validate" enctype="multipart/form-data" onsubmit="return iframeCallback(this, navTabAjaxDone);">
		<input type="hidden" name="merch.code" value="#(merch.code)">
		<div class="pageFormContent " layoutH="56">
	<div class="divider"></div>
				<label>商户文件：</label>
				<ul class="images">
				  	#for(item:fileNameList)
					    <li>
					    	<div class="col-sm-12 col-md-12">
						        <div class="thumbnail">
					    		<img src="admin/merch/showFile?fileName=#(item)&merchCode=#(merch.code)" width="300px" height="300px" alt="Picture" >
						        <div class="buttonActive"><div class="buttonContent"><button type="button" onclick="imgdelect('#(item)', '#(merch.code)')">删除</button></div></div>
						        </div>
						    </div>
					    </li>
				  	#end
				  </ul>
				  </div>
	</form>

	
</div>
<script type="text/javascript">
$('.images').viewer();
function jsdownlaod(){
	window.location.href = "admin/merch/downloadQcodeJpg?merch=#(merch.code )";
}

function imgdelect(filename, merchCode){
	//alert("确定删除: " + merchCode + "//" + filename);
	alertMsg.confirm("确认删除此文件,注意:删除后不可恢复!", {
		 okCall: function(){
			 var filepathname = merchCode + "/" + filename;
			 alertMsg.info("确定删除: " + filepathname);
			 //window.location.href = "admin/merch/removeFile?key="+filepathname;
			 //callbackType: "closeCurrent"
//message: "操作成功"
//statusCode: "200"
			 $.ajax({
	              type: "get",
	              url: "admin/merch/removeFile?key="+filepathname,
	              dataType: "json",
	              success: function(data){
	            if(data.statusCode == "200"){
	              alertMsg.correct(data.message);
	              navTab.closeCurrentTab();
	        }else{
	           alertMsg.error(data.message);
	        }
	}
	}); 
		 },
		 cancelCall : function() {
			 //alertMsg.info("取消删除: " + merchCode + "//" + filename);
		 }
	});
	
}


var isIE = /msie/i.test(navigator.userAgent.toLowerCase()) && !window.opera; 
function filefujianChange(target) {
       var fileSize = 0;         
       if (isIE && !target.files) {     
         var filePath = target.value;     
         var fileSystem = new ActiveXObject("Scripting.FileSystemObject");        
         var file = fileSystem.GetFile (filePath);     
         fileSize = file.Size;    
       } else {    
        fileSize = target.files[0].size;     
        }   
        var size = fileSize / 1024;    
        if(size>1000){  
         alert("附件不能大于1M");
         target.value="";
         return
        }
        var name=target.value;
        var fileName = name.substring(name.lastIndexOf(".")+1).toLowerCase();
        if(fileName !="jpg" && fileName !="jpeg" && fileName !="pdf" && fileName !="png" && fileName !="dwg" && fileName !="gif" ){
          alert("请选择图片格式文件上传(jpg,png,gif,dwg,pdf,gif等)！");
            target.value="";
            return
        }
      }

</script>
